package com.clound.order.controller;

import com.clound.order.dto.OrderDTO;
import com.clound.order.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zzy on 2018/4/12.
 */
@RestController
public class SendMessageController {

    @Autowired
    private StreamClient streamClient;

    @GetMapping("/sendMsg")
    public void process(){
        Message message=MessageBuilder.withPayload("this is a stream msg").build();
        streamClient.output().send(message);
    }

    /**
     * 发送orderDto
     */
    @GetMapping("/sendMsgObj")
    public void processObj(){
        OrderDTO orderDTO=new OrderDTO();
        orderDTO.setOrderId("1234");
        Message message=MessageBuilder.withPayload(orderDTO).build();
        streamClient.output().send(message);
    }
}
